const mysql = require('mysql2/promise');
const dotenv = require('dotenv');

dotenv.config({ path: '.env.local' });

async function checkDatabase() {
  try {
    const connection = await mysql.createConnection({
      host: process.env.DB_HOST,
      user: process.env.DB_USER,
      password: process.env.DB_PASSWORD,
      database: process.env.DB_NAME
    });

    console.log('连接数据库成功');
    
    const [rows] = await connection.execute('SELECT id, title, category, source, publish_date FROM enterprise_policies LIMIT 10');
    
    console.log('数据库中的政策数据:');
    console.log(rows);
    
    await connection.end();
  } catch (error) {
    console.error('查询数据库失败:', error);
  }
}

checkDatabase(); 